//错误码
var error = {
    1: function(that) {
        that.$router.push('/main/err402')
    },
    2: function(that) {
        that.$router.push('/main/err401')
    },
    999999: function(that) {
        var src = that.$store.getters.src;
        var obj = {
            u: localStorage.getItem('ZULONGBIUSER'),
            p: localStorage.getItem('ZULONGBIPASSWORD')
        }
        if (obj.p === undefined) {
            that.$router.push('/login')
        } else {
            that.$http.jsonp(`${src}user/login.do`, {
                params: obj
            }).then(function(res) {
                var data = JSON.parse(JSON.parse(res.body));
                if (data.res === '0') {
                    that.$router.go(0)
                } else {
                    that.$router.push('/login');
                }
            })
        }
    }
};

export default {
    install(Vue) {
        Vue.prototype.getErrorMsg = function(errorCode) {
            /*if(errorCode == 30086){
            	window.location.href = "/error/signexpired"
            }else{
            	var errorMsg = error[errorCode] || "未知错误";
            	return errorMsg;
            }*/
            if (typeof error[errorCode] === "function") {
                return error[errorCode](this);
            }
        }
    }
}